<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //Array.isArray()
        //arr instanceof Array
         function reverse(arr) {
            // if(!Array.isArray(arr)) return console.log('请输入数组');
                // if(!(arr instanceof Array)) return console.log('请输入数组');
                 if(Object.prototype.toString.call (arr) !== '[object Array]') return console.log('请输入数组');
                var newArr = [];
                for (var i = arr.length - 1; i >= 0; i--) {
                    newArr[newArr.length] = arr[i];

                }
                return newArr;
        }
        // console.log(reverse(1, 2, 3));
        console.log(reverse([1, 2, 3]));

        //4. Object.prototype.toString.call(要检测的类型) 判断数据类型最精准的方法 这个方法是最牛逼的额没有之一  
        console.log(Object.prototype.toString.call(1));     //'[object Number]'
        console.log(Object.prototype.toString.call('好'));  //'[object String]'
        console.log(Object.prototype.toString.call(true));  //'[object Boolean]'
        console.log(Object.prototype.toString.call([]));    //'[object Array]'
        console.log(Object.prototype.toString.call({}));    //'[object Object]'
    </script>
</body>
</html>
